import numpy as np
import cv2

scr_video = 'E:/Research/2020ContrastiveLearningForSceneLabel/Data/20210329ExperimentData/round1/round1_ds.avi'
tar_video = 'E:/Research/2020ContrastiveLearningForSceneLabel/Data/20210329ExperimentData/round1/round1_ds_30fps.avi'

src = cv2.VideoCapture(scr_video)
video_width = int(src.get(cv2.CAP_PROP_FRAME_WIDTH))
video_height = int(src.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter(tar_video,fourcc,30.0,(video_width, video_height))

fno = 0
while True:
    
    ret, frame = src.read()
    if not ret:
        out.release()
        break
    out.write(frame)
    if fno % 100 == 1:
        print(fno)
    fno += 1